import 'package:flutter/material.dart';
import 'package:im_flutter_sdk_example/jsonserialize/message/data.dart';
import 'package:im_flutter_sdk_example/utils/global.dart';

/*
 *@功能: 小组消息列表
 *@author: lovecrosszhu
 *@date: 2021-02-03 16:03:03
 *@version: V1.0.0
*/
class GroupMessageProvider with ChangeNotifier {
  GroupMessage _messageModel;
  GroupMessage get messageData => _messageModel;
  Message _latestMessage;

  Message get latestMessage => _latestMessage;

  void loadMessage() async {
    var result = await G.req.group.loadGroupMessage();
    if (result == null) return;
    print("loadMessage result#######: $result");
    if (result.data['status'] == 1) {
      if (result.data['data'] != null) {
        _latestMessage = Message.fromJson(result.data['data']);
      }
    }
    // if (result.data['status'] == 1) {
    //   _messageModel = GroupMessage.fromJson(result.data);
    // }
    notifyListeners();
  }
}
